/*
** client.c for  in /u/all/caille_c/cu/minitalk/client
** 
** Made by carole cailleux
** Login   <caille_c@epitech.net>
** 
** Started on  Wed Feb 24 13:15:42 2010 carole cailleux
** Last update Fri Mar 12 19:56:42 2010 carole cailleux
*/

#include <stdlib.h>
#include <sys/types.h>
#include <signal.h>
#include "client.h"

int		gl_sig_ok = 1;

void		handle_sig(int sig)
{
  signal(SIGUSR1, handle_sig);
  if (sig == SIGUSR1)
    gl_sig_ok = 1;
}

void		init(int pid, char *str)
{
  int		i;

  i = 0;
  send_pid(pid);
  while (str[i])
    {
      dec_to_bin((int)str[i], pid);
      i++;
    }
  dec_to_bin(0, pid);
}

int		main(int ac, char **av)
{
  signal(SIGUSR1, handle_sig);
  if (ac == 3)
    init(my_getnbr(av[1]), av[2]);
  else
    {
      my_putstr("Wrong arguments\n");
      exit(EXIT_FAILURE);
    }
  return (0);
}
